POV-Ray : Newsgroups : povray.general : The Language of POV-Ray : Re: The Language of POV-Ray Server Time
11 Aug 2024 13:19:41 EDT (-0400)
  Re: The Language of POV-Ray  
From: Nigel Stewart
Date: 13 Mar 2000 01:24:50
Message: <38CC8967.69CBD4F9@nigels.com>
> In all seriousness, object oriented would work very well for POV-Ray, since it
> models... objects!

Jon,

You havn't raised XML in this thread - I think it is quite an 
appropriate opportunity to talk about it.  People are used to
the HTML idea generally, but HTML has evolved into a bit of a
mess, so it may not be a great idea to suggest XML from this
viewpoint... (sigh)

Anyway, XML is a way of passing data which avoids the need
for a hard-coded parser in the application.  The "file format"
is editable, meaning that it can be extended quite easily
and that new tags for specific purposes do not crash parsers
that don't know what to do with the information.  Also,
somthing using XML would be familiar to anyone who's used
HTML or XML for something else. 

An example of what code may look like?

sphere { 
  <0, 0, 0>, 1
  pigment { Blue }
  translate -0.5*x  
}


Perhaps:

<POVSCENE>
  <SPHERE>
    <POSITION> 0,0,0 </POSITION>
    <RADIUS>   1.0   </RADIUS>
    <PIGMENT>
      <COLOR> BLUE </COLOR>
    </PIGMENT>
    <TRANSLATE> -0.5*x </TRANSLATE>
  </SPHERE>
</POVSCENE>

The question is, I suppose, whether all these TAGS would be 
intimidating to a new user, or someone who has spent a lot
of time learning the current scheme.

One thing to keep in mind is that editors could be a lot
smarter using XML than would be possible with a custom
file format.  It would be very easy to allow a tree-edit
style, rather than flat text.  It would also be easy to 
guarantee a well-formed scene without running it through
POV to see if it parses alright.

I guess that XML would imply something of a hybrid mode
of editing between flat text and 3D modelling, which could
possibly unify these two ways of doing things.  (I think
I could edit a tree-based editor without a mouse, but I
think a lot of the time I'd rather point-click and select
a colour, rather than typing "Orange", at the other extreme,
die hards that want to edit XML tags, are always free to
do so, without loosing the niceness of drag-and-drop, and
gatgets like that.)

What happens if we want to add new attributes to 
a sphere?  For example, for a gravity similation 
system we also want the mass of the sphere...
In this situation, you extend the definition for
POV XML, add a tag <MASS> which is allowed to
occur in the scope of <SPHERE>, and on the programming
side, add a field to store the mass and initialise
it from the XML intermediate data in the XML parser.
POVray without support for the <MASS> tag, simply
ignores it.

One implication is that there are probably other efforts
to figure out generic DTD's (XML based file formats) for
3D objects, which could form the basis for a POV DTD.
In fact, by making all of the POV specific stuff optional
extensions, you have a good chance of importing and
exporting without running you files through conversion
tools.

I'm no XML expert, but it seems to me that it should at
least be considered, considering the advantages of it.

A few limitations of XML that come to mind - the typing
scheme is limited to "weak typing" which means that really
any text can be inserted between tags, whether it's supposed
to be a floating point number, radius, vector, or whatever.
So POV would probably still barf sometimes.

Nigel

--
Nigel Stewart (nig### [at] nigelscom)
Research Student, Software Developer
Y2K is the new millenium for the mathematically challenged.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.